#ifndef CONFIGMANAGER_H
#define CONFIGMANAGER_H

// Offer user information from config file

#include <QHostAddress>
#include <QString>
#include <QList>
#include <QRect>
#include <QFileInfoList>

#include "Define.h"

class ConfigManager : public QObject
{
	Q_OBJECT
	public:
		ConfigManager();
		bool Initialize(); //todo : load....
		bool NetworkConfigInitialize();
		bool IPNameConfigInitialize();
		IPInfo GetNetworkAddr(int number) const;
		int GetLogCapacity() const;

		QString GetDownloadPath() const;
		QString GetLogPath() const;
		char GetNetworkGroup() const;

		QString GetGroup() const;
		QString GetName() const;
		QString GetGroupName() const;
		QHostAddress GetLocalAddress() const;
		QHostAddress GetBroadcastAddress() const;
		bool IsMyInfo(QString groupName) const;
		bool IsMyInfo(QString group, QString name) const;

		int GetIPNamesCount() const;
		QString GetIPName(int idx, bool forWidget) const;
		QHostAddress GetIPNameAddress(QString ipName) const;
		QHostAddress GetIPNameAddress(int idx) const;

		int GetNetworkPort() const;

		QRect GetWindowSize() const;
		void SetWindowSize(int width, int height);
		void SaveToFile(QString fileName, QString backupName, const char *data);
		bool SaveToFile(QString fileName, const char *data);

		int GetSavedGroupList(QFileInfoList &list) const;
		int GetSavedMemberList(QString gName, QStringList &list) const;

		int SetShortcutEnable(bool enable);
		bool IsShortcutEnable();

	private:
		void ProcessIPs();

	private:
		QString _groupName;
		QString _group;
		QString _name;
		QHostAddress _addr;
		QHostAddress _broadCastAddr;
		char *_downloadPath;
		char *_logPath;
		char _netGroup;
		int _netPort;
		int _logCapacity;
		int _ips[4][4];
		IPInfo _ipInfo[4];
		QList<Client> _ipNames;
		QRect _rect;
		bool _shotcutEnabled;


	signals:
		void sigError(QString errStr);

};

ConfigManager *GetConfigManager();
#define CONFIG_MANAGER (GetConfigManager())
#endif // CONFIGMANAGER_H
